using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MySql.Data.MySqlClient;
using System.Data;
using System.Configuration;
using System.Web.UI;

namespace TestProject.Controllers
{

	[HandleError]
	public class HomeController : Controller
	{
		
		public ActionResult Index ()
		{
			BookController.filteredBookList = BookController.searchedBooks = TestProject.Book.getBooks();
			
			ViewData["Books"] = TestProject.Book.filtersearchedBooks(0, BookController.searchedBooks);
			ViewData["Count"] = BookController.searchedBooks.Count;
			
			if(Session["level"] != null)
			{
				if((int)Session["level"] == 1) return RedirectToAction ("../User");	
				else 
				{
					return RedirectToAction ("../Librarian");
				}
			}
			return View (ViewData);
		}
		
		public ActionResult user()
		{
			
			return View ();
		}
		
		public ActionResult error()
		{
			ViewData["Books"] = TestProject.Book.getBooks();
			ViewData["err"] = "Invalid Username/Password.  ";
			return View ("Index", ViewData);
		}
		
		public ActionResult Register()
		{
			return View();
		}
	}
}

